Skip to content

Translation filter on select field#101

Open
raimonesteve wants to merge 5 commits intoopenlabs:developfrom
raimonesteve:translation_filter
Open

Translation filter on select field#101
raimonesteve wants to merge 5 commits intoopenlabs:developfrom
raimonesteve:translation_filter

Conversation

@raimonesteve
Copy link
Copy Markdown
Contributor

When render some fields in template, this fields is a option, not value (for example selected fields). Add new filter to translate values from ir.translations.

@raimonesteve raimonesteve deleted the translation_filter branch October 15, 2013 15:06
@raimonesteve raimonesteve restored the translation_filter branch October 15, 2013 15:10
@raimonesteve raimonesteve reopened this Oct 15, 2013
@raimonesteve
Copy link
Copy Markdown
Contributor Author

I test more about selected fields to get label and not option.

In some cases, key, value are not exactly and don't find all translated labels in translation_filter. For example:

sale.state: cancel, cancelled
invoice.type: out_credit_note, Credit Note

I think a better option is clone select options in template and get it:

{% set invoice_type = {'out_invoice': _('Invoice'), 'out_credit_note': _('Credit Note')} %}
{{ type[invoice.type] }}

@raimonesteve
Copy link
Copy Markdown
Contributor Author

I improve values from selection fields use Model.fields_get. Get values from selection fields is more easy than add conditions or dict in jinja template (need afeter to translate).

raimonesteve@8537342

I don't know if "translation_filter" is the best name of this method/filter. Feedback?

Details https://groups.google.com/d/msg/tryton-dev/JVCYVFlVtxs/GsZI-QGB810J

@raimonesteve raimonesteve reopened this Oct 17, 2013
@sharoonthomas
Copy link
Copy Markdown

@raimonesteve could you send the translation of select fields as a new patch please ? It is an important contribution which we could include before 3.2 release

@sharoonthomas sharoonthomas changed the title Translation filter Translation filter on select field Jun 13, 2014
@raimonesteve
Copy link
Copy Markdown
Contributor Author

Hie Sharoon,

I try to resend pull request but I get "Travis error field"...

You could import/export commit raimonesteve@8537342 or copy code in main nereid project. You are free ;)

@sharoonthomas
Copy link
Copy Markdown

Sure, we will try :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants